package liuliu.throughwaring.control.task;

import android.content.Context;

import net.tsz.afinal.FinalDb;

import liuliu.throughwaring.control.net.HttpTask;
import liuliu.throughwaring.control.onload.IOnloadView;
import liuliu.throughwaring.model.InvokeReturn;

/**
 * Created by Administrator on 2015/11/25.
 */
public class GetViewTask {
    Context mContext;
    FinalDb db;
    HttpTask task;

    public GetViewTask(Context context) {
        mContext = context;
        db = FinalDb.create(context);
        task = new HttpTask(mContext);
    }

    public void getView(String controller, final IOnloadView iOnloadView) {

        task.start("GetView", "Controller=" + controller, null, new HttpTask.TaskListener() {
            @Override
            public void onTaskResult(boolean result, InvokeReturn invokeReturn) {
                if (result) {
                    if (iOnloadView != null) {
                        iOnloadView.getViewResult(true, invokeReturn.getMessage());
                    }
                } else {
                    if (iOnloadView != null) {
                        iOnloadView.getViewResult(false, "加载失败");
                    }
                }
            }
        });
    }
}
